package com.xbongbong.paas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * @author zcp
 * @version v1.0
 * @since v1.0
 */
@Getter
public enum FundAccountFlowTypeEnum {
    /**
     * 回款单为1，付款单为2, 其它收入单为3，其它支出单为4，资金调拨单（收入类型）为5，资金调拨单（支出类型）为6
     */
    ALL(0, "enum.fundAccountFlowType.name.all"),
    PAYMENT_SHEET(1, "enum.fundAccountFlowType.name.payment_sheet"),
    PAY_SHEET(2, "enum.fundAccountFlowType.name.pay_sheet"),
    OTHER_INCOME(3, "enum.fundAccountFlowType.name.other_income"),
    OTHER_EXPENSE(4, "enum.fundAccountFlowType.name.other_expense"),
    FUND_TRANSFER_IN(5, "enum.fundAccountFlowType.name.fund_transfer_in"),
    FUND_TRANSFER_OUT(6, "enum.fundAccountFlowType.name.fund_transfer_out"),
    ;
    /**
     * 类型code值
     */
    private Integer code;

    /**
     * 类型名称
     */
    private String name;

    FundAccountFlowTypeEnum() {
    }

    FundAccountFlowTypeEnum(Integer code, String name){
        this.code = code;
        this.name = name;
    }

    /**
     * 获取是流入类型的业务
     *
     * @return
     */
    public static List<Integer> getInTypes() {
        return Arrays.asList(PAYMENT_SHEET.getCode(), OTHER_INCOME.getCode(), FUND_TRANSFER_IN.getCode());
    }

    /**
     * 获取是流出类型的业务
     *
     * @return
     */
    public static List<Integer> getOutTypes() {
        return Arrays.asList(PAY_SHEET.getCode(), OTHER_EXPENSE.getCode(), FUND_TRANSFER_OUT.getCode());
    }

    /**
     * 获取资金账户收支情况类型下拉选的默认值列表
     *
     * @return
     */
    public static List<FundAccountFlowTypeEnum> getComboValues() {
        return Arrays.asList(FundAccountFlowTypeEnum.ALL, FundAccountFlowTypeEnum.PAYMENT_SHEET, FundAccountFlowTypeEnum.PAY_SHEET, FundAccountFlowTypeEnum.OTHER_INCOME,
                FundAccountFlowTypeEnum.OTHER_EXPENSE, FundAccountFlowTypeEnum.FUND_TRANSFER_IN);
    }

    /**
     * 获取需要所有查询的类型
     *
     * @return
     */
    public static List<Integer> getSearchTypes() {
        return Arrays.asList(FundAccountFlowTypeEnum.PAYMENT_SHEET.getCode(), FundAccountFlowTypeEnum.PAY_SHEET.getCode(), FundAccountFlowTypeEnum.OTHER_INCOME.getCode(),
                FundAccountFlowTypeEnum.OTHER_EXPENSE.getCode(), FundAccountFlowTypeEnum.FUND_TRANSFER_IN.getCode(), FundAccountFlowTypeEnum.FUND_TRANSFER_OUT.getCode());
    }

    /**
     * 根据code获取枚举码
     *
     * @return
     */
    public static FundAccountFlowTypeEnum getAccountTypeByCode(Integer code) {
        for (FundAccountFlowTypeEnum fundAccountFlowTypeEnumSen : FundAccountFlowTypeEnum.values()) {
            if (Objects.equals(code, fundAccountFlowTypeEnumSen.getCode())) {
                return fundAccountFlowTypeEnumSen;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
